<template>
    <div class="admin">
        <p class="title">问题提交
        </p>
        <el-row>
            <el-col :span="12" :offset="6">
                <el-form ref="form" :model="form" label-width="80px">
                    <el-form-item label="questionId">
                        <el-input v-model="form.questionId"></el-input>
                    </el-form-item>
                    <el-form-item label="score">
                        <el-input v-model="form.score"></el-input>
                    </el-form-item>
                    <el-form-item label="name">
                        <el-input v-model="form.name"></el-input>
                    </el-form-item>
                    <el-form-item label="answerValue">
                        <el-input v-model="form.answerValue"></el-input>
                    </el-form-item>
                    <el-form-item label="type">
                        <el-input v-model="form.type"></el-input>
                    </el-form-item>
                    <el-form-item label="issue">
                        <el-input v-model="form.issue"></el-input>
                    </el-form-item>
                    <el-form-item>
                        <el-button type="primary" @click="onSubmit">登录</el-button>
                    </el-form-item>
                </el-form>
            </el-col>
        </el-row>
    </div>
</template>

<script>
    import 'whatwg-fetch'
    var qs = require('qs');
    export default {
        name: 'admin',
        data() {
            return {
                form: {
                    questionId: '',
                    score: "",
                    name: "",
                    answerValue: "",
                    type: "",
                    issue: ""
                }
            }
        },
        methods: {
            onSubmit() {
                // console.log(this.form)
                fetch(`http://172.20.10.4:8080/addAnswer?${qs.stringify(this.form)}`)
                    .then(function(response) {
                        return response.json()
                    }).then(function(json) {
                        console.log('parsed json', json)
                    }).catch(function(ex) {
                        console.log('parsing failed', ex)
                    })
            }
        }
    }
</script>

<style scoped lang="less">
    .admin {
        .title {
            text-align: center;
            font-size: 30px;
            font-weight: bold;
        }
    }
</style>
